package com.iss.demo.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
public class MyWebConfigurer implements WebMvcConfigurer {
    @Autowired
    private PrereadConfig config;
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
//        /uploadFile/**：映射成的相对路径的位置
//        图片存放的绝对路径
//        如果img或其他的标签，资源为/uploadFile/**，自动去绝对路径去读取
        registry.addResourceHandler("/uploadFile/**").addResourceLocations("file:"+config.getUploadPath());
    }

}
